<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" >
    <button>计算</button>
    <script>
        //打车起步价13（三公里内），之后每多一公里增加5块钱，用户输入公里数就可以计算打车价格
        //如果有拥堵情况，总价格多收取10快去拥堵费
        var ipt = document.querySelector("input");
        var btn = document.querySelector("button");
        var car = (function(){
            var start = 13 ;//起步价
            var total = 0;//总价
            var yongd = 10;
            return{
                //正常的总价
                price :function(n){
                    if(n<=3){
                        total = start;
                    }else{
                        total = start + (n-3)*5;
                    }
                    return total;
                },
                yd:function(flag){
                   return flag?total +10 :total;
                }//拥堵的费用
                
            }
        })();
        console.log(car.price(5));
        console.log(car.yd(false));
    </script>
</body>
</html>